<!DOCTYPE html>
<html lang="zh-cmn-Hans">

<head>
    <meta charset="UTF-8">
    <meta name="viewport" content="width=device-width,initial-scale=1,user-scalable=0,viewport-fit=cover">
    <title>预约记录</title>
    <link rel="stylesheet" href="/static/css/weui.css" />
    <link rel="stylesheet" href="/static/css/example.css" />
    <style type="text/css">
    #imageStyle{
        width: 100%;
        max-height: 100%;
        vertical-align: top;
        border-radius: 35px;
        }
    .bn{
        position: relative;
        width: 184px;
        float: right;
        margin-left: auto;
        margin-right: auto;
        padding: 6px 12px;
        box-sizing: border-box;
        font-weight: 700;
        font-size: 10px;
        text-align: center;
        text-decoration: none;
        color: #fff;
        line-height: 1.41176471;
        border-radius: 4px;
        overflow: hidden;
        -webkit-tap-highlight-color: rgba(0,0,0,0);
        background-color: #07c160;
    }
    </style>
</head>

<body ontouchstart>
    <div class="container" id="container"></div>
    <script type="text/html" id="tpl_home">
        <div class="page">


            <div style='background-color: rgba(0,0,0,0); padding-top: 5%; padding-left: 3%; padding-right: 3%;'>
                <div class="weui-panel__bd">
                    <div class="weui-media-box weui-media-box_appmsg ">
                        <div class="weui-media-box__hd">
                            <img id="imageStyle" src="" alt="">
                        </div>
                        <div class="weui-media-box__bd">
                            <h4 id="userName" class="weui-media-box__title">用户名称</h4>
                            <p id="deviceNum" class="weui-media-box__desc">设备数量: 1</p>
                        </div>
                    </div>
                </div>
            </div>
            <HR style="FILTER:alpha(opacity=90,finishopacity=0,style=1)" width="100%"color=#ffffff SIZE=1>

            <div id='history' class="weui-form-preview__item">
                <label id="devices" class="weui-form-preview__label" style="margin:6px 10px;text-align-last:left">设备id</label>
                <label id="times" class="weui-form-preview__label" style="margin:6px 100px;text-align-last:right">操作时间</label>
                
            </div>

            </div>


            <div class="weui-footer weui-footer_fixed-bottom">
            <p class="weui-footer__links">
                <p class="weui-footer__link">访问官网</p>
                <a href="http://www.zjnnhj.com" class="weui-footer__link">zjnnhj@zjnnhj.com</a>
            </p>
            <p class="weui-footer__links">
                <p class="weui-footer__link">联系我们</p>
                <a href="http://www.zjnnhj.com" class="weui-footer__link">18106532996</a>
            </p>
            <p class="weui-footer__text">Copyright © 2020 牛能环保</p>
        </div>
        </div>


        <script src="/static/js/jquery.min.js"></script>
        <script src="/static/js/weui.min.js"></script>
        <script type="text/javascript" src="/static/js/jweixin-1.4.0.js"></script>
        <script src="/static/js/zepto.min.js"></script>
        <script src="/static/js/example.js"></script>



        <script type="text/javascript">
            $(function() {

                function getQueryString(name) {
                    var reg = new RegExp("(^|&)" + name + "=([^&]*)(&|$)", "i");
                    var r = decodeURI(window.location.search).substr(1).match(reg);
                    if (r != null) return (r[2]);
                    return null;
                };


                $(document).ready(function() {
                    // 获取code
                    var code = getQueryString('code');

                    /*
                    $.ajax({
                        url: 'http://gzh.zjnnhj.com/niuneng/getUserDevice',
                        type: "post",
                        data: JSON.stringify({
                            'userId': code
                        }),
                        dataType: "json",
                        success: function(data) {
                            if (data.result != null)
                                {$('#userName').html(data.result[0].userid);}
                            
                        }
                    });*/
                                    

                    //  获取用户名下设备
                    $.ajax({
                            url: 'http://gzh.zjnnhj.com/niuneng/getHistory',
                            type: "post",
                            data: JSON.stringify({
                                'userId': code
                            }),
                            dataType: "json",
                            success: function(data) {
                                console.log(data)
                                //data = JSON.parse(data);
                                str = '';
                                userid = '';
                                if (data.errcode == 0){
                                    if (data.result.length>0){
                                        if (userid == ''){
                                            $('#userName').html(data.result[0].userid);
                                            userid = data.result[0].userid;
                                        }
                                        str += '<label id="devices" class="weui-form-preview__label" style="margin:6px 10px;text-align-last:left">设备id</label><label id="times" class="weui-form-preview__label" style="margin:6px 100px;text-align-last:right">操作时间</label>'
                                        for(i=0;i<data.result.length; i++){
                                            str += '<label  class="weui-form-preview__label" style="margin:6px 10px;text-align-last:left">' + data.result[i].deviceid +  '</label><label  class="weui-form-preview__label" style="margin:6px 50px;text-align-last:right">' + data.result[i].times + '</label>';
                                        }
                                    }else{
                                        str += '<div style="position: fixed;top:10em;right: 10em;color: gray;">没有操作历史</div>'
                                    }
                                }
                                
                                $('#history').html(str);
                            }
                    });
                                     
                    
                  });

                        
                    });
        </script>

    </script>
</body>
</body>

</html>